﻿@{
    ViewBag.Title = "Maintenance";
    Layout = "~/Views/Shared/_Layout.cshtml";
}


@using Common.BaseLibrary.Authorization
@using DepartmentWork.Model
@model DepartmentWork.Model.MaintenanceWorkState



<div class="page-header">
    <div class="pull-left">
        <ol class="breadcrumb visible-sm visible-md visible-lg">
            <li><a href="index.html"><i class="icon fa fa-home"></i>主页</a></li>
            <li class="active"><a href="#"><i class="fa fa-envelope"></i>运维项目管理</a></li>
        </ol>
    </div>
</div>
@{
    if (ViewBag.CreateProjectFlag == "True")
    {
    <div class="alert alert-success">
        <button type="button" class="close" data-dismiss="alert">×</button>
        <strong>&emsp;工作发布成功！</strong>
    </div>
    }
    if (ViewBag.CreateProjectFlag == "False")
    {
    <div class="alert alert-danger">
        <button type="button" class="close" data-dismiss="alert">×</button>
        <strong>&emsp;工作发布失败！</strong> @ViewBag.Info
    </div>
    }
}

<style>
   ul>.active {
       font-weight:bold
   }
   .bootstrap-select  {
       width: 100%;
   }
    
</style>





<div class="row">
    <div class="col-lg-12">
        <div class="panel">
            <div class="panel-heading bk-bg-primary">
                <h6><i class="fa fa-table red"></i><span class="break"></span>运维项目列表</h6>
                @if (ViewBag.IsAdmin == true)
                { 
                    <div class="panel-actions">
                        <a data-toggle="modal" data-target="#myModal" class="bk-margin-5 btn btn-default  btn-sm" style="background-color: #ECEDF0">&nbsp;&nbsp;新增运维项目&nbsp;&nbsp;</a>
                    </div>
                }

            </div>
            <div class="panel-body">
                <div class="tabs">
                    <ul class="nav nav-tabs">
                        <li class="active">
                            <a href="#overview" style="color:black"  data-toggle="tab">运行中</a>
                        </li>
                        <li class="">
                            <a href="#edit" style="color:black" data-toggle="tab">已下线</a>
                        </li>
                    </ul>
                    <div class="tab-content">
                        <div id="overview" class="tab-pane active">
                            <div class="panel-body">
                                <div class="table-responsive">
                                    <table class="table table-hover">
                                        <thead>
                                            <tr>
                                                <th style="text-align: center">项目编号</th>
                                                <th style="text-align: center">运维项目名称</th>
                                                <th style="text-align: center">创建日期</th>
                                                <th style="text-align: center">业务类型</th>
                                                <th style="text-align: center">关级/署级</th>
                                                <th style="text-align: center">负责人</th>
                                                <th style="text-align: center">运维工作</th>
                                            </tr>
                                        </thead>
                                        <tbody>
                                            @if (this.Model.ManintenanceNO.Tables[0].Rows.Count != 0)
                                            {
                                                for (int i = 0; i < this.Model.ManintenanceNO.Tables[0].Rows.Count; i++)
                                                {
                                                    var item = this.Model.ManintenanceNO.Tables[0].Rows[i];
                                                <tr>
                                                   <td style="text-align: center;color:black">@item["appops_no"]</td>
                                                    
                                                   <td style="text-align: center"><a style="color:blue" href="@Url.Action("Particulars", "Maintenance", new { area = "PerationAndMaintenanceArea", projectId = item["appops_id"] })">@item["appops_name"]</a></td>
                                                    <td style="text-align: center;color:black">@Convert.ToDateTime(item["appops_time"]).ToString("yyyy-MM-dd")</td>
                                                    <td style="text-align: center;color:black">@item["appops_businesstype"]</td>
                                                    <td style="text-align: center;color:black">@item["appops_workrank"]</td>
                                                    <td style="text-align: center;color:black">@item["appops_principal"]</td>
                                                    <td style="text-align: center;color:black">
                                                          @if (ViewBag.currentUser != null)
                                                          {
                                                              foreach (ProjectManintenanceAppopsViewModel user in ViewBag.currentUser)
                                                               {
                                                                   if (user.appops_id.ToString() == item["appops_id"].ToString())
                                                                   {
                                                                       <a onclick="deleteid('@item["appops_id"]')" data-toggle="modal" data-target="#TaskBookCreateModal"  style="color:blue">&nbsp;&nbsp;新增&nbsp;&nbsp;</a>
                                                                   }
                                                               }
                                                   
                                                          }
                                                     
                                                    <a onclick="jilu('@item["appops_id"]')" data-toggle="modal" data-target="#NeiRong" style="color:blue">&nbsp;&nbsp;查询&nbsp;&nbsp;</a>
                                                    </td>
                                                </tr>
                                                }
                                            }

                                        </tbody>
                                    </table>
                                </div>
                                <div class="bk-margin-5 btn-group" style="float: right">
                                    @Html.ShowPageNavigate((int)ViewData["pageIndexExecute"], (int)ViewData["pageSizeExecute"], (int)ViewData["totalExecute"])
                                </div>
                            </div>
                        </div>
                        <div id="edit" class="tab-pane updateProfile">
                            <div class="panel-body">
                                <div class="table-responsive">
                                    <table class="table table-hover">
                                        <thead>
                                            <tr>
                                                <th style="text-align: center">项目编号</th>
                                                <th style="text-align: center">运维项目名称</th>
                                                <th style="text-align: center">创建日期</th>
                                                <th style="text-align: center">业务类型</th>
                                                <th style="text-align: center">运维级别</th>
                                                <th style="text-align: center">负责人</th>
                                                <th style="text-align: center">结束日期</th>
                                            </tr>
                                        </thead>
                                        <tbody>

                                            @if (this.Model.ManintenanceYES.Tables[0].Rows.Count != 0)
                                            {
                                                for (int i = 0; i < this.Model.ManintenanceYES.Tables[0].Rows.Count; i++)
                                                {
                                                    var item = this.Model.ManintenanceYES.Tables[0].Rows[i];
                                                     
                                                <tr>
                                                    <td style="text-align: center;color:black">@item["appops_no"]</td>
                                                    @if (ViewBag.IsAdmin == true)
                                                    {
                                                        <td style="text-align: center"><a style="color:black" href="@Url.Action("Particulars", "Maintenance", new { area = "PerationAndMaintenanceArea", projectId = item["appops_id"] })">@item["appops_name"]</a></td>
                                                    }
                                                    @if (ViewBag.IsAdmin == false)
                                                    {
                                                        <td style="text-align: center;color:black">@item["appops_name"]</td>
                                                    }
                                                    <td style="text-align: center;color:black">@Convert.ToDateTime(item["appops_time"]).ToString("yyyy-MM-dd")</td>
                                                    <td style="text-align: center;color:black">@item["appops_businesstype"]</td>
                                                    <td style="text-align: center;color:black">@item["appops_workrank"]</td>
                                                    <td style="text-align: center;color:black">@item["appops_principall"]</td>
                                                    <td style="text-align: center;color:black">@Convert.ToDateTime(item["appops_overtime"]).ToString("yyyy-MM-dd")</td>
                                                </tr>
                                                }
                                            }

                                        </tbody>
                                    </table>
                                </div>
                                <div class="bk-margin-5 btn-group" style="float: right">
                                    @Html.ShowPageNavigate((int)ViewData["pageIndexFinish"], (int)ViewData["pageSizeFinish"], (int)ViewData["totalFinish"])
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>




<!-- 模态框（Modal） -->

<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <link href="~/Assets/plugins/bootstrap-select/bootstrap-select.min.css" rel="stylesheet" />
    <script src="~/Assets/plugins/bootstrap-select/bootstrap-select.min.js"></script>
    <link href="~/Assets/plugins/bootstrap-datepicker/css/datepicker3.css" rel="stylesheet" />
    <link href="~/Assets/plugins/bootstrap-datepicker/css/datepicker-theme.css" rel="stylesheet" />
    <script src="~/Assets/plugins/bootstrap-datepicker/js/bootstrap-datepicker.js"></script>
    <script src="~/Assets/plugins/chosen/chosen.jquery.min.js"></script>
    <script src="~/Assets/js/pages/form-elements.js"></script>
    <script src="~/Assets/js/jquery.validate.min.js"></script>

    <script>
        $(document).ready(function () {
            $("#yanzheng_id").validate({
                rules: {
                    tb_appops_xiangmuname: { required: true },
                    tb_appops_department: { required: true },
                    tb_appops_businesslinkman: { required: true },
                    tb_appops_describe: { required: true }


                },
                messages: {
                    tb_appops_xiangmuname: { required: "项目名称不能为空" },
                    tb_appops_department: { required: "主管部门不能为空" },
                    tb_appops_businesslinkman: { required: "业务联系人不能为空" },
                    tb_appops_describe: { required: "描述不能为空" }


                },
                errorPlacement: function (error, element) {
                    error.appendTo(element.next("span.appops_xiangmuname"));
                    error.appendTo(element.next("span.appops_department"));
                    error.appendTo(element.next("span.appops_businesslinkman"));
                    error.appendTo(element.next("span.Describe_class"))


                }
            });
            $("span.appops_xiangmuname").css("color", "red");
            $("span.appops_department").css("color", "red");
            $("span.appops_businesslinkman").css("color", "red");
            $("span.Describe_class").css("color", "red");
        })

        $("#selcet_DTime").datepicker({
            autoclose: true,
            pickerPosition: "bottom-right"
        });
        //window.onload = function () {
        //    $("#datetimepicker").datepicker();
        //};
    </script>

    <style>
        .btn-default {
            color: #333;
            background-color: #FFF;
            border-color: #CCC;
            height: 34px;
        }
       #table_CreateProject td {
       padding-left: 5px;
       padding-top: 5px
   }
        #table_CreateProjectt td {
       padding-left: 5px;
       padding-top: 5px
   }
    </style>

    <div class="modal-dialog" style="width:50%;text-align:center">
        <div class="modal-content">
            <form id="yanzheng_id" action="@Url.Action("InserMaintenance", "Maintenance", new { area = "PerationAndMaintenanceArea" })" method="POST">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                    <h4 class="modal-title" id="myModalLabel">新增运维项目</h4>
                </div>
                <div id="div_CreateProject" class="modal-body">


                       <table id="table_CreateProject">
                           <tr>
                                 <td>运维项目名称:</td>
                                 <td>
                                 <input id="t_appops_xiangmuname" style="border-color: cornflowerblue" name="tb_appops_xiangmuname" class="form-control" placeholder="Text" type="text">
                                 <span class="appops_xiangmuname"></span>
                                 </td>
                                 <td>创建人：</td>
                                 <td>
                                 <input value="@ViewBag.myName" readonly="true" id="t_appops_chuangjianname" style="border-color: cornflowerblue" name="tb_appops_chuangjianname" class="form-control" placeholder="Text" type="text">
                                 </td>
                           </tr>

                             <tr>
                                 <td>关级/署级:</td>
                                 <td>
                                 <select  name="select_appops_workrank" class="form-control selectpicker">
                                     <option value="关级">关级</option>
                                     <option value="署级">署级</option>
                                 </select>
                                 </td>
                                 <td>项目级别：</td>
                                 <td>
                                  <select name="select_appops_rank" class="form-control selectpicker">
                                    <option value="一级">一级</option>
                                    <option value="二级">二级</option>
                                    <option value="三级">三级</option>
                                  </select>
                                 </td>
                           </tr>
                            <tr>
                                 <td>项目负责人：</td>
                                 <td>
                                 <select name="select_WorkLeader" id="select_ProjectLeader" class="form-control selectpicker" multiple="multiple">
                                @{
                                    List<UserInfoViewModel> userList = (List<UserInfoViewModel>)TempData["UserList"];
                                    if (userList != null)
                                    {
                                        for (int i = 0; i < userList.Count(); i++)
                                        {
                                            var item = userList[i];
                                            if (userList[i] == userList[0])
                                            {
                                    <option selected="selected" value="@item.UserId">@item.UserName</option>
                                            }
                                            else
                                            {
                                    <option value="@item.UserId">@item.UserName</option>
                                            }
                                        }
                                    }
                                }
                              </select>
                                 </td>
                                 <td>业务主管部门：</td>
                                 <td>
                                 <input id="t_appops_department" style="border-color: cornflowerblue" name="tb_appops_department" class="form-control" placeholder="Text" type="text">
                                 <span class="appops_department"></span>
                                 </td>
                           </tr>
                           <tr>
                            <td>业务类型:</td>
                                 <td>
                                 <input id="t_appops_yewuleixing" style="border-color: cornflowerblue" name="tb_appops_yewuleixing" class="form-control" placeholder="Text" type="text">
                                 <span class="appops_businesstype"></span>
                                 </td>
                                <td>用户人数：</td>
                                 <td>
                                   <input id="text-input" style="border-color: cornflowerblue" name="tb_appops_quantity" class="form-control" placeholder="Text" type="text">
                                <span class="workName_class"></span>
                                 </td>

                           </tr>
                            <tr>
                                <td>关联系统名称：</td>
                                 <td>
                                        <input id="text-input0" style="border-color: cornflowerblue" name="tb_appops_relevancename" class="form-control" placeholder="Text" type="text">
                            <span class="workName_class"></span>
                                 </td>
                                 <td>使用频率：</td>
                                 <td>
                                      <input id="text-input1" style="border-color: cornflowerblue" name="tb_appops_frequency" class="form-control" placeholder="Text" type="text">
                            <span class="workName_class"></span>
                                 </td>
                           </tr>
                             <tr>
                                 <td>业务联系人和电话:</td>
                                 <td colspan="3">
                                 <input id="t_appos_businesslinkman" style="border-color: cornflowerblue" name="tb_appops_businesslinkman" class="form-control" placeholder="Text" type="text">
                                 <span class="appops_businesslinkman"></span>
                                 </td>
                               
                           </tr>
                            <tr>
                                 <td>系统关联方式：</td>
                                 <td  colspan="3">  <input id="text-input2" style="border-color: cornflowerblue" name="tb_appops_relevanceway" class="form-control" placeholder="Text" type="text">
                            <span class="workName_class"></span></td>
                           </tr>
                            <tr>
                                 <td>功能描述：</td>
                                 <td colspan="3">
                                      <textarea id="t_appops_describe" name="tb_appops_describe" rows="5" class="form-control" placeholder="Content.."></textarea>
                            <span class="Describe_class"></span>
                                 </td>
                           </tr>
                            
                       </table>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">
                        关闭
                    </button>
                    <input type="submit" value="提交" class="btn btn-primary" />
                </div>
            </form>
        </div>
        <!-- /.modal-content -->
    </div>
    <!-- /.modal -->
</div>



<!-- 增加记录 模态框（Modal） -->
<script>
    function deleteid(bugId) {

        $.ajax({
            type: "POST",
            //url: "/KSManager/PerationAndMaintenanceArea/Maintenance/reacord_id",
            url:'@Url.Action("reacord_id","Maintenance",new{area="PerationAndMaintenanceArea"})',
            data: "roleId=" + bugId,
            error: function () { alert("服务器出错！"); },
            success: function (data) {
                $("#tb_appops_id").val(data["appops_id"]);
            }
        });
    }

</script>
<div class="modal fade" id="TaskBookCreateModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">

    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
                    &times;
                </button>
                <h4 class="modal-title" id="myModalLabel">新增记录</h4>
            </div>
            <form id="reacord_id" enctype="multipart/form-data" action="@Url.Action("Reacord_Insert", "Maintenance", new { area = "PerationAndMaintenanceArea" })", method="POST" >

                <div class="modal-body">
                      <input type="hidden" name="hid_ProjectId" />
                    <table id="table_CreateProjectt">
                        <tr>
                              <td>运维操作类型：</td>
                              <td><select name="select_record_operationtype" class="form-control selectpicker">
                                <option value="上线">上线</option>
                                <option value="变更">变更</option>
                                <option value="故障">故障</option>
                                <option value="下线">下线</option>
                                <option value="其他">其他</option>
                            </select>
                            <input type="hidden" id="tb_appops_id" name="hid_appops_id"/>
                            <input type="hidden" name="hid_appops_name_id" value="@ViewBag.NAMEID"/>
                              </td>
                              <td>操作日期：</td>
                              <td style="vertical-align:middle" >
                              <div  class="input-append date"  style="display:inline-block; height:20px"  id="selcet_DTime"  data-date="@DateTime.Now.ToString("yyyy-MM-dd")" data-date-format="yyyy-mm-dd">
                                <input  id="selcet_text_DTime_id"  name="selcet_text_DTime" size="10" type="text"  value="@DateTime.Now.ToString("yyyy-MM-dd")">
                             <span class="add-on"><i class="icon-th"></i></span>
                             </div>
                              </td>
                        </tr>
                        <tr>
                              <td>内容：</td>
                              <td  colspan="5">
                                  <textarea name="tb_record_content" class="form-control" rows="5"></textarea>
                            <span class="t_record_content"></span>
                              </td>
                        </tr>
                        <tr>
                             <td>附件：</td>
                             <td  colspan="5">
                             <input name="tb_record_accessory" style="border-color: cornflowerblue" placeholder="Text" type="file">
                             </td>
                        </tr>
                    </table>
                 
                    
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">
                        关闭
                    </button>
                    <input type="submit" value="新增" class="btn btn-primary" />
                </div>

            </form>
        </div>
        <!-- /.modal-content -->
    </div>
    <!-- /.modal -->
</div>











<!-- 记录内容 模态框（Modal） -->

<script>
    function jilu(bugId) {

        $.ajax({
            type: "POST",
            //url: "/KSManager/PerationAndMaintenanceArea/Maintenance/reacord_selcet",
            url:'@Url.Action("reacord_selcet","Maintenance",new{area="PerationAndMaintenanceArea"})',
            data: "roleId=" + bugId,
            error: function () { alert("服务器出错！"); },
            success: function (data) {
                 
                $("#nr_record_content").text(data);
            }
        });
    }
    
</script>
<div class="modal fade" id="NeiRong" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">

    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
                    &times;
                </button>
                <h4 class="modal-title" id="myModalLabell" style="color:black">已有的运维记录</h4>
            </div>
            <form enctype="multipart/form-data" action="@Url.Action("Reacord_updat", "Maintenance", new { area = "PerationAndMaintenanceArea" })", method="POST" >

                <div class="modal-body">
                    <input type="hidden" name="hid_ProjectId" />
                 
                    <br />

                    <div class="row">
                        <div >
                           @* <label id="nr_record_content" style="width: 100%" class="col-md-8 control-label" for="text-input"></label>*@
                          <textarea id="nr_record_content" class="form-control" rows="10" readonly="readonly" style="background-color:white;color:black"></textarea>
                        </div>
                    </div>
                    <br />

                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">
                        关闭
                    </button>
                </div>

            </form>
        </div>
        <!-- /.modal-content -->
    </div>
    <!-- /.modal -->
</div>